﻿using MDIDemo.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevMy.Vou
{
    public partial class Form_SetParamDefaultValue : Form_BaseDialog
    {
        public Form_SetParamDefaultValue()
        {
            InitializeComponent();
        }

        public ParamDefaultMaxMinModel paramDefaultMaxMinModel;

        public void Ini()
        {
            base.SetComponent();
        }
        /// <summary>
        /// 窗体状态
        /// </summary>
        /// <param name="WinType">-1：查看，0：修改，1：增加</param>
        public void SetWinType(int WinType)
        {
            base.WinType = WinType;
        }

        protected override void DisplayComponent(string id)
        {
            if (id != null)
            {
                string Sql = string.Format(@"Select id
                    ,paramName
                    ,chinaName
                    ,defaultValue
                    From vou_equipmentparamer
                    Where id = {0}
                    Order by id", id);
                DataTable dataTable = base.class_MySqlDataBase.GetDataTable(Sql);
                if (dataTable != null && dataTable.Rows.Count == 1)
                {
                    DataRow dataRow = dataTable.Rows[0];
                    if (dataRow != null)
                    {
                        this.labelControl2.Text = dataRow["paramName"].ToString();
                        this.labelControl1.Text = dataRow["chinaName"].ToString();
                        this.spinEdit1.Value = Convert.ToDecimal(dataRow["defaultValue"]);
                    }
                }
                dataTable.Dispose();
            }
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            paramDefaultMaxMinModel = new ParamDefaultMaxMinModel();
            paramDefaultMaxMinModel.id = base.id;
            paramDefaultMaxMinModel.defaultValue = this.spinEdit1.Value;
            this.DialogResult = DialogResult.OK;
        }
    }
}
